<template>
    <el-select clearable :loading="loading" filterable v-model="cateId" placeholder="请选择文章分类" :size="size" @change="$emit('input',cateId)">
        <el-option v-for="item in list" :key="`shequ-${item.id}`" :label="item.name" :value="item.id"></el-option>
    </el-select>
</template>
<script>
import { get } from '@/assets/js/http';
export default {
    props:{
        size:String,
        value:String|Number
    },
    data() {
        return {
            cateId: '',
            list: [],
            loading: false
        }
    },
    watch:{
        value(){
            this.cateId = this.value
        }
    },
    created() {
        this.getList()
    },
    methods: {
        async getList() {
            try {
                this.loading = true
                let data = await get({
                    url: '/admin/wiki.newsCate/index',
                    params: {
                        page: 1,
                        limit: 9999
                    }
                })
                this.list = data.list
            } finally {
                this.loading = false
            }
        }
    }
}
</script>